(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var AppClass = function () {
	function AppClass() {
		_classCallCheck(this, AppClass);

		this._eventContext = null;
		this._loadingPanel = null;
		this._pages = [];
		this._routes = [];
		this._user = null;
	}

	_createClass(AppClass, [{
		key: "login",
		value: function login(user) {
			this._user = Object.assign({}, user);
		}
	}, {
		key: "crudGridInstance",
		value: function crudGridInstance() {
			return $(".crud-grid").dxDataGrid("instance");
		}
	}, {
		key: "getFormInstance",
		value: function getFormInstance() {
			return $("#form").dxForm("instance");
		}
	}, {
		key: "getEventContext",
		value: function getEventContext() {
			return this._eventContext;
		}
	}, {
		key: "setEventContext",
		value: function setEventContext(v) {
			this._eventContext = v;
		}
	}, {
		key: "showLoading",
		value: function showLoading(message) {
			message = message || '正在加载...';

			this._loadingPanel = $("#loadpanel").dxLoadPanel({
				shadingColor: "rgba(0,0,0,0.4)",
				position: { of: "body" },
				visible: true,
				showIndicator: true,
				showPane: true,
				shading: true,
				closeOnOutsideClick: false,
				message: message
			}).dxLoadPanel("instance");
		}
	}, {
		key: "hideLoading",
		value: function hideLoading() {
			if (this._loadingPanel !== null) {
				this._loadingPanel.hide();
				this._loadingPanel = null;
			}
		}
	}, {
		key: "registerCrud",
		value: function registerCrud(opt) {
			this.pages.push(opt);
		}
	}, {
		key: "registerRoute",
		value: function registerRoute(opt) {
			this.routes.push(opt);
		}
	}, {
		key: "pages",
		get: function get() {
			return this._pages;
		}
	}, {
		key: "routes",
		get: function get() {
			return this._routes;
		}
	}, {
		key: "user",
		get: function get() {
			return this._user;
		}
	}]);

	return AppClass;
}();

var App = exports.App = new AppClass();


},{}],2:[function(require,module,exports){
'use strict';

var _app = require('./app');

var _util = require('./util');

var _util2 = _interopRequireDefault(_util);

var _page = require('./page');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_app.App.registerCrud({
	route: 'authority', //路由名称
	url: $.config('apiUrl') + 'auth',
	title: '权限管理', //分页标题
	capable: {
		create: true
	},
	columns: [{
		dataField: 'id',
		caption: '编号'
	}, {
		dataField: 'jobId',
		caption: '工种' //名称
	}, {
		dataField: 'moduleId',
		caption: '功能模块'
	}, {
		minWidth: 120,
		caption: '操作',
		buttons: [{
			title: '编辑',
			url: '#/authority/edit/{{id}}' //#/路由名称/edit/{{id}}
		}]
	}],
	form: {
		readOnly: false,
		showColonAfterLabel: true,
		showValidationSummary: false,
		colCount: 1,
		beforeSubmit: function beforeSubmit(form, id) {
			form.option('formData', Object.assign({ type: 'admin' }, form.option('formData')));

			return true;
		},
		items: [{
			dataField: 'id',
			validationRules: [{ type: "required" }],
			label: { text: '编号' }
		}, {
			dataField: 'jobId',
			validationRules: [{ type: "required" }],
			label: { text: '工种' }
		}, {
			dataField: 'moduleId',
			validationRules: [{ type: "required" }],
			label: { text: '功能模块' }
		}]
	}
});

_app.App.registerCrud({
	route: 'user', //路由名称
	url: $.config('apiUrl') + 'user',
	title: '用户管理', //分页标题
	capable: {
		create: true
	},
	columns: [{
		dataField: 'id',
		caption: '编号'
	}, {
		dataField: 'name',
		caption: '用户名' //名称
	}, {
		minWidth: 120,
		caption: '操作',
		buttons: [{
			title: '编辑',
			url: '#/user/edit/{{id}}' //#/路由名称/edit/{{id}}
		}]
	}],
	form: {
		readOnly: false,
		showColonAfterLabel: true,
		showValidationSummary: false,
		colCount: 1,
		items: [{
			dataField: 'name',
			validationRules: [{ type: "required" }],
			label: { text: '用户名' }
		}]
	}
});

_app.App.registerCrud({
	route: 'log', //路由名称
	url: $.config('apiUrl') + 'log',
	title: '日志查询', //分页标题
	capable: {
		create: true
	},
	columns: [{
		dataField: 'id',
		caption: '编号'
	}, {
		dataField: 'date',
		caption: '时间',
		cellTemplate: function cellTemplate(ele, data) {
			$(ele).text(moment(data.data.date).format('YYYY-MM-DD HH:mm:ss'));
		}
	}, {
		dataField: 'type',
		caption: '功能模块' //名称
	}, {
		dataField: 'description',
		caption: '操作记录',
		cellTemplate: function cellTemplate(ele, da) {
			var data = JSON.parse(da.data.description);
			var type = data.status ? data.status.name || '' : '';
			var shift = data.shift ? data.shift.name || '' : '';
			$(ele).text('\u72B6\u6001:' + type + ',\u73ED\u6B21:' + shift);
		}
	}, {
		dataField: 'userName',
		caption: '操作人' //名称
	}, {
		minWidth: 120,
		caption: '操作',
		buttons: [{
			title: '编辑',
			url: '#/log/edit/{{id}}' //#/路由名称/edit/{{id}}
		}]
	}],
	form: {
		readOnly: false,
		showColonAfterLabel: true,
		showValidationSummary: false,
		colCount: 1,
		beforeSubmit: function beforeSubmit(form, id) {
			form.option('formData', Object.assign({ type: 'admin' }, form.option('formData')));

			return true;
		},
		items: [{
			dataField: 'id',
			validationRules: [{ type: "required" }],
			label: { text: '编号' }
		}, {
			dataField: 'date',
			validationRules: [{ type: "required" }],
			editorType: 'dxDateBox',
			label: { text: '时间' }
		}, {
			dataField: 'moduleId',
			validationRules: [{ type: "required" }],
			label: { text: '功能模块' }
		}, {
			dataField: 'description',
			validationRules: [{ type: "required" }],
			label: { text: '操作记录' }
		}, {
			dataField: 'siteName',
			validationRules: [{ type: "required" }],
			label: { text: '站点名称' }
		}, {
			dataField: 'employeeId',
			validationRules: [{ type: "required" }],
			label: { text: '操作人' }
		}]
	}
});

_app.App.registerRoute({
	name: 'params',
	onLoad: function onLoad(context, $container) {
		var page = new _page.Page($container);
		page.crudLayout({ title: '系统参数' });

		page.content.html('<div class="formSubmit"></div>' + '<div class="formBody"></div>');

		var formInstance = page.content.find('.formSubmit').dxForm({
			formData: {},
			colCount: 3,
			items: []
		}).dxForm('instance');

		page.content.find('.formBody').dxToolbar({
			items: [{
				location: 'after',
				widget: 'dxButton',
				options: {
					type: 'success',
					text: '保存',
					onClick: function onClick() {
						var form = formInstance.option('formData');
						_util2.default.postForm($.config('apiUrl') + 'system/save', form).then(function (res) {
							if (res.errcode === 200) {
								new DevExpress.ui.notify({ message: '保存成功' }, 'success', 1000);
							} else {
								new DevExpress.ui.notify({ message: '保存失败:' + res.errmsg }, 'warning', 1500);
							}
						});
					}
				}
			}]
		});

		$.get($.config('apiUrl') + 'system/list').then(function (res) {
			var data = res.data;
			formInstance.option({
				formData: data,
				items: [{
					label: { text: '任务间隔时间' },
					dataField: 'taskInterval'
				}, {
					label: { text: '营业开始时间' },
					dataField: 'shopBegin'
				}, {
					label: { text: '营业结束时间' },
					dataField: 'shopClose'
				}, {
					label: { text: '接口Key' },
					dataField: 'apiKey'
				}, {
					label: { text: '接口URL' },
					dataField: 'apiUrl'
				}]
			});
		});
	}
});


},{"./app":1,"./page":3,"./util":4}],3:[function(require,module,exports){
"use strict";

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Page = exports.Page = function () {
	function Page($container) {
		_classCallCheck(this, Page);

		this.$container = $container;
		this.$content = $container;
	}

	_createClass(Page, [{
		key: "crudLayout",
		value: function crudLayout(opt) {
			var data = Object.assign({ title: '未设置' }, opt),
			    html = "<div class=\"app-content-body \">\n\t\t  <div class=\"bg-light lter b-b wrapper-md hidden-print\">\n\t\t    <h1 class=\"m-n font-thin h3\">{{title}}</h1>\n\t\t  </div>\n\t\t  <div>\n\t\t    <div class=\"crud-container crud-reset\">\n\t\t    </div>\n\t\t  </div>\n\t\t</div>";

			this.$container.html(Mustache.render(html, data));
			this.$content = this.$container.find(".crud-container");

			return this;
		}
	}, {
		key: "content",
		get: function get() {
			return this.$content;
		}
	}]);

	return Page;
}();


},{}],4:[function(require,module,exports){
'use strict';

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Util = function () {
	function Util() {
		_classCallCheck(this, Util);
	}

	_createClass(Util, [{
		key: 'formatXbm',
		value: function formatXbm(xbm) {
			if (xbm == '2') return '女';else if (xbm == '1') return '男';else return xbm;
		}
	}, {
		key: 'crudStore',
		value: function crudStore(url, options) {

			var SERVICE_URL = url;
			options = $.extend({
				onDataArrived: function onDataArrived(data) {
					return data;
				}
			}, options);

			return new DevExpress.data.CustomStore($.extend({}, options, {

				load: function load(loadOptions) {

					var u = new Url(SERVICE_URL);

					u.query._param = JSON.stringify(loadOptions);

					return $.getJSON(u).then(function (resp, status, xhr) {

						if (resp.success) {
							resp = {
								status: 'success',
								data: resp.items
							};
						} else {
							resp = {
								status: 'success',
								totalCount: resp.totalCount,
								data: resp.data
							};
						}

						return options.onDataArrived(resp);
					});
				},

				byKey: function byKey(key) {
					var u = new Url(SERVICE_URL);
					u.path += "/" + encodeURIComponent(key);

					return $.getJSON(u).then(function (resp) {
						return resp;
					});
				},

				insert: function insert(values) {
					return $.post(SERVICE_URL, values).always(function (resp) {
						$.crudStoreResp = resp.responseJSON;
						return resp;
					});
				},

				update: function update(key, values) {
					var u = new Url(SERVICE_URL);
					u.path += "/" + encodeURIComponent(key);

					return $.ajax({
						url: u,
						method: "PUT",
						data: values
					}).always(function (resp) {
						$.crudStoreResp = resp.responseJSON;
						return resp;
					});
				},

				remove: function remove(key) {
					var u = new Url(SERVICE_URL);
					u.path += "/" + encodeURIComponent(key);

					return $.ajax({
						url: u,
						method: "DELETE"
					});
				}

			}));
		}
	}, {
		key: 'postForm',
		value: function postForm(url, data) {
			return $.ajax({
				url: url,
				data: JSON.stringify(data),
				contentType: "application/json",
				dataType: 'json',
				type: 'post'
			});
		}
	}]);

	return Util;
}();

exports.default = new Util();


},{}]},{},[2]);
